package com.gaswell.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gaswell.mapper.JhRtuConfigMapper;
import com.gaswell.mapper.ZtAlarmMapper;
import com.gaswell.pojo.JhRtuConfig;
import com.gaswell.pojo.ModbusLog;
import com.gaswell.pojo.ZtAlarm;
import com.gaswell.service.JhRtuConfigService;
import com.gaswell.service.ZtAlarmService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 采气井日数据 服务实现类
 * </p>
 *
 * @author Lei Wang
 * @since 2022-05-24
 */
@Service
@DS("mysql")
public class ZtAlarmServiceImpl extends ServiceImpl<ZtAlarmMapper, ZtAlarm> implements ZtAlarmService {

    @Override
    public Page getByPage(int current, int size, String jh) {
        QueryWrapper<ZtAlarm> ztAlarmQueryWrapper = new QueryWrapper<ZtAlarm>();
        ztAlarmQueryWrapper.eq("jh", jh);
        ztAlarmQueryWrapper.orderByDesc("alarmtime");
        Page<ZtAlarm> page = new Page<>(current, size);
        Page<ZtAlarm> ztAlarmPage = baseMapper.selectPage(page, ztAlarmQueryWrapper);
        return ztAlarmPage;
    }

    @Override
    public List getLast(String jh) {
        List last = baseMapper.getLast(jh);
        return last;
    }
}
